package com.fengwk.deeplearning.core;

import org.nd4j.linalg.api.ndarray.INDArray;
import org.nd4j.linalg.ops.transforms.Transforms;

public class TanhUnitCompute implements UnitCompute {
	
	private static final long serialVersionUID = -513859534865270662L;

	private INDArray A;
	
	@Override
	public INDArray activate(INDArray Z) {
		A = Transforms.tanh(Z);
		return A;
	}

	@Override
	public INDArray dActivate(INDArray Z) {
		return Transforms.pow(A.rsub(1), 2);
	}

}
